/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package com.xpn.xwiki.store.hibernate;

import org.junit.jupiter.api.Test;
import org.xwiki.test.junit5.mockito.ComponentTest;
import org.xwiki.test.junit5.mockito.InjectMockComponents;

import com.xpn.xwiki.XWikiContext;

import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

/**
 * Unit tests for {@link HibernateAttachmentRecycleBinStore}.
 *
 * @version $Id$
 */
@ComponentTest
class HibernateAttachmentRecycleBinStoreTest
{
    @InjectMockComponents
    private HibernateAttachmentRecycleBinStore store;

    @Test
    void restoreFromRecycleBinWhenNoAttachmentWithIndexFound() throws Exception
    {
        HibernateAttachmentRecycleBinStore spyStore = spy(this.store);
        doReturn(null).when(spyStore).getDeletedAttachment(anyLong(), any(XWikiContext.class), anyBoolean());

        // Verify we return null when no attachment is found.
        assertNull(spyStore.restoreFromRecycleBin(null, 0, null, false));
    }
}
